/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TelaMatrizParse.java
 *
 * Created on 09/10/2008, 20:34:34
 */

package sintelo.visao;

import sintelo.glc.Gramatica;
import sintelo.glc.Regra;
import sintelo.glc.TabelaParse;
import sintelo.visao.realce.Realces;
import sintelo.visao.tabelas.Tabelas;

/**
 *
 * @author phireis
 */
public class TelaMatrizParse extends javax.swing.JFrame {

    private Gramatica gramatica;

    /** Creates new form TelaMatrizParse */
    public TelaMatrizParse(TabelaParse tabela) {
        this.gramatica = tabela.getGramatica();
        initComponents();

        panel.setLeftComponent(Tabelas.criaTabelaParse(tabela));
        StringBuilder sb = new StringBuilder();
        int num = 0;
        for(Regra r : gramatica.getRegras()){
            sb.append(++num);
            sb.append(' ');
            sb.append(r);
            sb.append('\n');
        }

        txtGramatica.setText(sb.toString());
        Realces.getRealceGramatica().aplica(txtGramatica);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panel = new javax.swing.JSplitPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtGramatica = new javax.swing.JTextPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Matriz de parse");

        txtGramatica.setEditable(false);
        jScrollPane1.setViewportView(txtGramatica);

        panel.setRightComponent(jScrollPane1);

        getContentPane().add(panel, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

   

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSplitPane panel;
    private javax.swing.JTextPane txtGramatica;
    // End of variables declaration//GEN-END:variables

}
